<?php

/**
 * Framework_Site_Peopletab
 *
 * @author      Ian Szewczyk <roamzero@gmail.com>
 * @copyright   (c) 2007 Ian Szewczyk. All rights reserved.
 * @license     http://www.opensource.org/licenses/bsd-license.php
 * @package Framework
 * @filesource
 */


/**
 * Framework_Site_Peopletab
 *
 * @author Ian Szewczyk <roamzero@gmail.com>
 * @package Framework
 */
class Framework_Site_Peopletab extends Framework_Site_Common
{
	/**
	 * $domain
	 *
	 * @access      public
	 * @var         string      $domain       Domain
	 */
	public $domain;

	/**
	 * __construct
	 *
	 * @author Ian Szewczyk <roamzero@gmail.com>
	 * @access public
	 */
	public function __construct()
	{
		$this->name = 'Peopletab';
		$this->domain = preg_replace('/^(www\.)(.+)/i', '$2', $_SERVER['HTTP_HOST']);
		//	        $path = FRAMEWORK_BASE_PATH.'/Framework/Site/'.$this->name.'/Config/'.$this->configFile;
		//
		//	     	$result = Framework_Conf::load($path);
		//	     	if (PEAR::isError($result)) {
		//    			 throw new Exception('Could not load config file from '.$path);
		//			}
		 
		//			$this->userField = 'idSiteUser';
		//	     	$this->userTable = 'siteuser';
		//			$this->installPath = $this->getUriPath();
		//			$this->dsn = Framework_Conf::getConfig('peopletab','dsn');
		//			$this->domain = Framework_Conf::getConfig('peopletab','domain');
		//			$this->defaultUser = '1'; // Anonymous
		//			$this->userClass = 'Peopletab';
			
		parent::__construct();
	}





	/**
	 * prepare
	 *
	 * @access public
	 * @return mixed True on success, PEAR_Error on failure
	 */
	public function prepare()
	{
		 
		// HERE: Look for remote login GET and redirect if found
		//	     	if (isset($_GET['remoteLogin']) && preg_match('/^([a-zA-Z0-9])+([a-zA-Z0-9._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9._-]+)+$/',$_GET['remoteLogin'])) {
		//		     	if (isset($_GET['from']) && preg_match('/^http:\/\/[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]{1,3}\/.*$/i',$_GET['from'])) {
		//	     			$uriFrom = $_GET['from'];
		//		     		$remoteLogin = explode('@',$_GET['remoteLogin']);
		//		     		if (strcasecmp($this->domain,$remoteLogin[1]) != 0) {
		//			     		$redirect = 'Location: http://'.$remoteLogin[1].'/'.$remoteLogin[0].'/User/RemoteLoginUnlock?uri_from='.$uriFrom;
		//		    			header($redirect);
		//			     		exit(0);
		//		     		} else {
		//		     			// PEAR error
		//		     			return PEAR::raiseError('Invalid Domain');
		//		     		}
		//	     		} else {
		//	     			// PEAR error
		//	     			return PEAR::raiseError('Invalid "from" Argument');
		//	     		}
		//
		//	     	}
		//////////////////////////////
		 
		//	     	if($this->owner->isValid) {
		//				if($this->owner->skin) $this->skinDir = $this->owner->skin;
		//				if($this->owner->css)  $this->css = $this->owner->css;
		//				if($this->owner->customCSS) $this->customCSS = $this->owner->getCustomCSS();
		//				if($this->owner->customHeader) $this->customHeader = $this->owner->getCustomHeader();
		//			}
		return true;
		 
	}

	//	     public function pluginStart(&$module)
	//	     {
	//	     	$moduleMeta = Framework_Conf::getConfig('peopletab','moduleRegistry');
	//	     	$universalPlugins = Framework_Conf::getConfig('peopletab','plugins');
	//	     	if ($moduleMeta[$module->moduleName]){
	//	     		if (is_array($typePlugins = $universalPlugins[($moduleMeta[$module->moduleName]['level'])])) {
	//	     			foreach ($typePlugins as $plugin => $val){
	//	     				$plugin = Framework_Plugin::factory($plugin);
	//	     				if (!PEAR::isError($plugin))
	//	     					Framework_Plugin::register($plugin);
	//	     			}
	//	     		}
	//	     		if (is_array($universalPlugins['all'])) {
	//		     		foreach ($universalPlugins['all'] as $plugin => $val){
	//		     				$plugin = Framework_Plugin::factory($plugin);
	//		     				if (!PEAR::isError($plugin))
	//		     					Framework_Plugin::register($plugin);
	//		     		}
	//	     		}
	//
	//	     	}
	//
	//	     	if (is_array($pluginArray = $moduleMeta[$module->moduleName]['plugins'])) {
	//	     		foreach ($pluginArray AS $plugin) {
	//	     			$plugin = Framework_Plugin::factory($plugin);
	//	     			if (!PEAR::isError($plugin))
	//	     				Framework_Plugin::register($plugin);
	//	     		}
	//	     	}
	//
	//	     }

	 

	//	     /**
	//     	  * __destruct
	//          *
	//          * @access public
	//          * @return void
	//          */
	//		 public function __destruct()
	//	     {
	//	          parent::__destruct();
	//	     }
	   
	   
	   
}
?>